<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
</head>
<body>
<script type="text/javascript">
    //JSON依旧是一个变量
    let clazz = {
        id:123
    };
    console.log(typeof clazz);
    console.log(clazz["id"]);//key是个字符串类型

    let clazz1 = {
        oneclass : [
            {
                name:"张三",
                age:22,
                tag:["没礼貌","没脑子"]
            }
        ],//学生对象
        createDate : new Date(),//创建日期
        id : 1,//班级编号
        name : "scnwc",//班级名字
        sum : function(){
            return this.oneclass.length;
        }//方法返回个值,一般不会有
    };
    console.log(clazz1.id);
    console.log(clazz1.createDate);
    console.log(clazz1.name);
    console.log(clazz1.oneclass[0]);

    /* //不能解析 let s= "{'name':'小敏','age':'16'}";
    let x = eval(s);//字符串——>JSON
    let x = JSON.parse(s);
    console.log(x);*/
</script>
</body>
</html>